import { http } from "@/utils/http";
import { baseUrlApi, filerEmptyVal } from "../utils";

/** 获取基础档案-门店管理列表 */
export const getStorePage = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/store/page"), {
    params: filerEmptyVal(params)
  });
};

/** 获取基础档案-门店管理列表 */
export const getStoreSimplePage = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/store/simple/page"), {
    params: filerEmptyVal(params)
  });
};

/** 基础档案-门店管理列表-新增门店 */
export const storeAdd = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/store/add"), { data });
};

/** 基础档案-门店管理列表-编辑门店 */
export const storeUpdate = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/store/update"), { data });
};

/** 基础档案-门店管理列表-删除门店 */
export const storeDelete = (id?: object) => {
  return http.request<any>("post", baseUrlApi(`/store/delete?id=${id}`));
};

/** 获取基础档案-门店管理列表详情 */
export const getStoreDetail = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/store/detail"), { params });
};

/** 基础档案-门店管理列表-门店状态启用禁用 */
export const storeChangeStatus = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/store/change/status"), {
    data
  });
};

/** 导入门店列表 */
export const importStore = (data?: any) => {
  return http.request<any>(
    "post",
    `/erpPlatApi/store/import/store`,
    {
      data,
      params: {
        isShowErrTips: false
      }
    },
    {
      headers: {
        "Content-Type": "multipart/form-data"
      }
    }
  );
};

/** 导出门店列表 */
export const exportStore = (params?: any) => {
  return http.request<any>(
    "get",
    `/erpPlatApi/store/export/store`,
    { params: filerEmptyVal(params) },
    { responseType: "blob" }
  );
};

/** 预警金额上限导入 */
export const importWarning = (data?: any) => {
  return http.request<any>(
    "post",
    `/erpPlatApi/store/import/warning/top`,
    {
      data,
      params: {
        isShowErrTips: false
      }
    },
    {
      headers: {
        "Content-Type": "multipart/form-data"
      }
    }
  );
};
